package com.sc.server.system.auth.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import com.sc.server.system.auth.service.IUserRoleService;
import com.sc.server.system.auth.entity.UserRole;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
/**
 * <p>
 * 用户与角色对应关系 前端控制器
 * </p>
 *
 * @author zw
 * @since 2020-03-05
 */
@Api(description = "用户与角色对应关系 接口")
@RestController
@RequestMapping("/auth/userRole")
public class UserRoleController {
	@Autowired
	private IUserRoleService userRoleService;
/*	@PostMapping("page")
    @ApiOperation("获取数据列表")
	public PageEntity<UserRole> findListByPage(@RequestBody BaseQueryVo<UserRole> queryVo){
                     return userRoleService.queryPage(queryVo);	}
	@ApiOperation("根据ID查找数据")
	@GetMapping("/{id}")
	public UserRole find(@PathVariable("id") String id){
		UserRole userRole = userRoleService.selectById(id);
			if(userRole==null){
			throw new BusinessRuntimeException("查询不到此id的数据");
			}
			return userRole;
	}

	@ApiOperation("添加数据")
	@PostMapping
	public UserRole addItem(@RequestBody UserRole userRole){
			boolean isOk = userRoleService.insert(userRole);
			if(isOk){
			return userRole;
			}
			throw new BusinessRuntimeException("新增失败！");
	}

	@ApiOperation("更新数据")
	@PutMapping
	public UserRole updateItem(@RequestBody UserRole userRole){
		boolean isOk = userRoleService.updateById(userRole);
		if(isOk){
		return userRole;
		}
		throw new BusinessRuntimeException("更新失败！");
	}

	@ApiOperation("删除数据")
	@DeleteMapping("{id}")
	public void deleteItem(@PathVariable("id") String id){
		boolean isOk = userRoleService.deleteById(id);
		if(!isOk){
		throw new BusinessRuntimeException("数据删除失败");
		}
		}*/
	}
